package com.gitee.service.impl;

import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gitee.mapper.OrderItemMapper;
import com.gitee.pojo.OrderItem;
import com.gitee.service.IOrderItemService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class OrderItemServiceImpl extends ServiceImpl<OrderItemMapper, OrderItem> implements IOrderItemService {

    @Transactional
    @Override
    public Boolean deleteByOrderIds(List<Integer> orderIds) {
        LambdaUpdateWrapper<OrderItem> updateWrapper = new UpdateWrapper<OrderItem>().lambda()
                .in(!CollectionUtil.isEmpty(orderIds), OrderItem::getOrderId, orderIds);
        return super.remove(updateWrapper);
    }
}
